package com.twu.biblioteca;

/**
 * Created with IntelliJ IDEA.
 * User: Timmy
 * Date: 8/7/13
 * Time: 2:18 PM
 * To change this template use File | Settings | File Templates.
 */
public class User {


    private final String name;
    private final String email;
    private final String phoneNumber;
    private String password;
    public static int baseLibraryNumber = 1111110;
    private final Integer userLibraryNumber;

    public User(String name, String email, String phoneNumber, String password) {
        this.name = name;
        this.email = email;
        this.phoneNumber = phoneNumber;
        this.password = password;
        this.userLibraryNumber = baseLibraryNumber + 1;
        baseLibraryNumber+=1;
    }

    public String getMembershipDetails() {
        return String.format("Name: %s\nEmail: %s\nPhone Number: %s\n",name,email,phoneNumber);
    }

    public String libraryNumber() {
        return formattedLibraryNumber();
    }

    private String formattedLibraryNumber(){
        return userLibraryNumber.toString().substring(0,3)+"-"+userLibraryNumber.toString().substring(3);
    }

    public Boolean comparePasswordWith(String password) {
        return password.equals(this.password);
    }
}
